Þ ¥bonds€¬cell_resultsÞ Ù$e4d0ad7b-9e72-45c7-9eb9-0ed06567aef8Š¦queuedÂ¤logs�§runningÂ¦output†¤body£6.2¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÿê=¸°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$e4d0ad7b-9e72-45c7-9eb9-0ed06567aef8¹depends_on_disabled_cellsÂ§runtimeÎ7ŠÚµpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$470eaa98-4073-11eb-349d-e9c34e5478c2Š¦queuedÂ¤logs�§runningÂ¦output†¤bodyÚªA JuMP Model
Maximization problem with:
Variables: 2
Objective function type: AffExpr
`JuMP.AffExpr`-in-`MathOptInterface.LessThan{Float64}`: 1 constraint
`JuMP.VariableRef`-in-`MathOptInterface.GreaterThan{Float64}`: 2 constraints
`JuMP.VariableRef`-in-`MathOptInterface.LessThan{Float64}`: 2 constraints
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: GLPK
Names registered in the model: con, x, y¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÿèzþ°°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$470eaa98-4073-11eb-349d-e9c34e5478c2¹depends_on_disabled_cellsÂ§runtimeÏ   [S±µpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$9b4e18a3-669f-4bab-8c22-565428ebf299Š¦queuedÂ¤logs�§runningÂ¦output†¤bodyÙ)opacity (generic function with 2 methods)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÿåq©a°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$9b4e18a3-669f-4bab-8c22-565428ebf299¹depends_on_disabled_cellsÂ§runtimeÎ šÂµpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$cdda279d-60bf-495c-b796-a62e5dd1d699Š¦queuedÂ¤logs�§runningÂ¦output†¤bodyÙ(opacity (generic function with 1 method)¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÿåqrÒ°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$cdda279d-60bf-495c-b796-a62e5dd1d699¹depends_on_disabled_cellsÂ§runtimeÎ -Œuµpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$8bc3d43a-1460-498b-baa8-fcb9a3338457Š¦queuedÂ¤logs�§runningÂ¦output†¤bodyÚ=<div class="markdown"><p>To access variables from the model that are hidden by a let block, use the alternative syntax:</p>
<p>â›”ï¸� Don&#39;t:</p>
<pre><code class="language-julia">value&#40;y&#41;</code></pre>
<p>âœ”ï¸� Do:</p>
<pre><code class="language-julia">value&#40;model&#91;:y&#93;&#41;</code></pre>
</div>¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÿÔÌE‘°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$8bc3d43a-1460-498b-baa8-fcb9a3338457¹depends_on_disabled_cellsÂ§runtimeÎ >-µpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$ce6d95f3-d745-4215-844c-727c9d90861dŠ¦queuedÂ¤logs�§runningÂ¦output†¤bodyÚZ<div class="markdown"><h2>Part 2: secret definitions</h2>
<p>JuMP&#39;s macros create global variables, which are not seen by Pluto. For example, <code>@variable&#40;model, 0 &lt; x &lt; 1&#41;</code> defines a global variable called <code>x</code>, while Pluto thinks that the global variable <code>x</code> was <em>referenced</em>, not assigned.</p>
<p>There are two ways to solve this.</p>
<h3>Part 2a: <code>let</code> block &#40;recommended&#41;</h3>
<p>Place the macros inside a <code>let</code> block, to locally scope any secretly created variables.</p>
<p>â›”ï¸� Don&#39;t:</p>
<pre><code class="language-julia">begin
	model &#61; Model&#40;GLPK.Optimizer&#41;

	@variable&#40;model, 20 &lt; y &lt; 30&#41;
	# global variable y is now defined, but Pluto does not know it

	...
end</code></pre>
<p>âœ”ï¸� Do:</p>
<pre><code class="language-julia">let
	global model &#61; Model&#40;GLPK.Optimizer&#41;

	@variable&#40;model, 20 &lt; y &lt; 30&#41;
	# locally scoped variable y is now defined. Pluto does not know about it, but since the global scope is unaffected, this is fine

	...
end</code></pre>
</div>¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÿÔÌ,Ë°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$ce6d95f3-d745-4215-844c-727c9d90861d¹depends_on_disabled_cellsÂ§runtimeÎ ßáµpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$759c0a90-bb03-456e-bbf6-8bf80b249c07Š¦queuedÂ¤logs�§runningÂ¦output†¤bodyÚ><div class="markdown"><h2>Part 1: model mutations</h2>
<p>Because JuMP&#39;s macros <em>modify</em> a model, it is important the the <strong>model construction is contained in a single cell</strong>. Use a <code>let</code> block &#40;more in Part 2&#41;.</p>
<p>â›”ï¸� Don&#39;t:</p>
<pre><code class="language-julia">model &#61; Model&#40;GLPK.Optimizer&#41;</code></pre>
<pre><code class="language-julia">@variable&#40;model, 20 &lt; y &lt; 30&#41;</code></pre>
<p>âœ”ï¸� Do:</p>
<pre><code class="language-julia">let
	global model &#61; Model&#40;GLPK.Optimizer&#41;

	@variable&#40;model, 20 &lt; y &lt; 30&#41;

	...
end</code></pre>
<h4>optimize&#33;</h4>
<p>Similarly, <code>optimize&#33;</code> will <em>modify</em> the model, so I recommend calling it in the same cell as the model construction.</p>
<p>If, for the purpose of a narrative, you need the optimization to happen in a different cell, then use a &quot;new state, new name&quot; trick:</p>
<pre><code class="language-julia">begin
	optimize&#33;&#40;model&#41;
	model_optimized &#61; model
end</code></pre>
<p>In other cells, reference <code>model_optimized</code> to access <code>model</code> to guarantee that the model optimization has already happened:</p>
<pre><code class="language-julia"># in other cells
value&#40;model_optimized&#91;:x&#93;&#41;</code></pre>
</div>¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÿÔÌk°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$759c0a90-bb03-456e-bbf6-8bf80b249c07¹depends_on_disabled_cellsÂ§runtimeÎ 	§%µpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$69a565bc-e250-4105-9b6b-3b9879dcb417Š¦queuedÂ¤logs�§runningÂ¦output†¤bodyÙ"OPTIMAL::TerminationStatusCode = 1¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÿê*=:°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$69a565bc-e250-4105-9b6b-3b9879dcb417¹depends_on_disabled_cellsÂ§runtimeÎJæ4µpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$95e0721d-321f-478c-8d02-0ac070008a5bŠ¦queuedÂ¤logs�§runningÂ¦output†¤bodyÚ­A JuMP Model
Maximization problem with:
Variables: 2
Objective function type: AffExpr
`JuMP.AffExpr`-in-`MathOptInterface.LessThan{Float64}`: 1 constraint
`JuMP.VariableRef`-in-`MathOptInterface.GreaterThan{Float64}`: 2 constraints
`JuMP.VariableRef`-in-`MathOptInterface.LessThan{Float64}`: 2 constraints
Model mode: AUTOMATIC
CachingOptimizer state: ATTACHED_OPTIMIZER
Solver name: GLPK
Names registered in the model: con, x, y¤mimeªtext/plain¬rootassignee©model_opt²last_run_timestampËAÚÿê@°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$95e0721d-321f-478c-8d02-0ac070008a5b¹depends_on_disabled_cellsÂ§runtimeÏ   (|0µµpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$d5b9c438-b1e7-4417-870f-afdfc4ee7672Š¦queuedÂ¤logs�§runningÂ¦output†¤bodyÚG<div class="markdown"><h1>How to use JuMP in Pluto?</h1>
<p>JuMP uses macros to form a domain-specific language. That is very cool&#33; but unfortunately, Pluto has trouble understanding code with macros. This is a difficult problem that we currently working on, and it is getting closer to being fixed&#33;</p>
<p>For any cell, it is important that Pluto correctly understands which variables are <strong>referenced</strong> and which are <strong>defined</strong>. Pluto&#39;s runtime uses this information to keep your global scope clean, and to reactively re-run cells.</p>
</div>¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÿÔËêd°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$d5b9c438-b1e7-4417-870f-afdfc4ee7672¹depends_on_disabled_cellsÂ§runtimeÎ såµpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$2717450b-8e9d-4be4-9156-53b2020a2e5dŠ¦queuedÂ¤logs�§runningÂ¦output†¤bodyÙ]Max 5 x + 3 y
Subject to
 con : x + 5 y â‰¤ 3.0
 x â‰¥ 0.0
 y â‰¥ 0.0
 x â‰¤ 1.0
 y â‰¤ 30.0
¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÿèÙ0°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$2717450b-8e9d-4be4-9156-53b2020a2e5d¹depends_on_disabled_cellsÂ§runtimeÍ8[µpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$946b13ae-65f2-4844-a38a-693b2f01bad4Š¦queuedÂ¤logs�§runningÂ¦output†¤body£0.4¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÿêCx§°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$946b13ae-65f2-4844-a38a-693b2f01bad4¹depends_on_disabled_cellsÂ§runtimeÍËµpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$b99f3213-f2c4-4d85-b34c-a60052571af3Š¦queuedÂ¤logs�§runningÂ¦output†¤bodyÙ-<div class="markdown"><h1>Example</h1>
</div>¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÿÔÌ[%°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$b99f3213-f2c4-4d85-b34c-a60052571af3¹depends_on_disabled_cellsÂ§runtimeÎ “—µpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$2e3d4b69-786e-4ccb-91ec-3b98f1f568e0Š¦queuedÂ¤logs‘ˆ¤lineÿ£msg’Úº[32m[1m  Activating[22m[39m new project at `/tmp/jl_1TF91H`
[32m[1m    Updating[22m[39m registry at `~/.julia/registries/General.toml`
[32m[1m   Resolving[22m[39m package versions...
[32m[1m   Installed[22m[39m CodecBzip2 â”€â”€â”€â”€â”€â”€â”€â”€â”€ v0.7.2
[32m[1m   Installed[22m[39m GLPK_jll â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ v5.0.0+0
[32m[1m   Installed[22m[39m JSONSchema â”€â”€â”€â”€â”€â”€â”€â”€â”€ v0.3.4
[32m[1m   Installed[22m[39m GLPK â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ v0.14.14
[32m[1m   Installed[22m[39m MutableArithmetics â”€ v0.2.22
[32m[1m   Installed[22m[39m JuMP â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ v0.21.10
[32m[1m   Installed[22m[39m MathOptInterface â”€â”€â”€ v0.9.22
[32m[1m    Updating[22m[39m `/tmp/jl_1TF91H/Project.toml`
 [90m [60bf3e95] [39m[92m+ GLPK v0.14.14[39m
 [90m [4076af6c] [39m[92m+ JuMP v0.21.10[39m
 [90m [7f904dfe] [39m[92m+ PlutoUI v0.7.64[39m
[32m[1m    Updating[22m[39m `/tmp/jl_1TF91H/Manifest.toml`
 [90m [6e696c72] [39m[92m+ AbstractPlutoDingetjes v1.3.2[39m
 [90m [6e4b80f9] [39m[92m+ BenchmarkTools v1.6.0[39m
 [90m [b99e7846] [39m[92m+ BinaryProvider v0.5.10[39m
 [90m [fa961155] [39m[92m+ CEnum v0.4.2[39m
 [90m [49dc2e85] [39m[92m+ Calculus v0.5.2[39m
 [90m [d360d2e6] [39m[92m+ ChainRulesCore v1.25.1[39m
 [90m [9e997f8a] [39m[92m+ ChangesOfVariables v0.1.10[39m
 [90m [523fee87] [39m[92m+ CodecBzip2 v0.7.2[39m
 [90m [944b1d66] [39m[92m+ CodecZlib v0.7.8[39m
 [90m [3da002f7] [39m[92m+ ColorTypes v0.12.1[39m
 [90m [bbf7d656] [39m[92m+ CommonSubexpressions v0.3.1[39m
 [90m [34da2185] [39m[92m+ Compat v4.16.0[39m
 [90m [864edb3b] [39m[92m+ DataStructures v0.18.22[39m
 [90m [163ba53b] [39m[92m+ DiffResults v1.1.0[39m
 [90m [b552c78f] [39m[92m+ DiffRules v1.15.1[39m
 [90m [ffbed154] [39m[92m+ DocStringExtensions v0.9.5[39m
 [90m [53c48c17] [39m[92m+ FixedPointNumbers v0.8.5[39m
 [90m [f6369f11] [39m[92m+ ForwardDiff v0.10.38[39m
 [90m [60bf3e95] [39m[92m+ GLPK v0.14.14[39m
 [90m [cd3eb016] [39m[92m+ HTTP v0.9.17[39m
 [90m [47d2ed2b] [39m[92m+ Hyperscript v0.0.5[39m
 [90m [ac1192a8] [39m[92m+ HypertextLiteral v0.9.5[39m
 [90m [b5f81e59] [39m[92m+ IOCapture v0.2.5[39m
 [90m [83e8ac13] [39m[92m+ IniFile v0.5.1[39m
 [90m [3587e190] [39m[92m+ InverseFunctions v0.1.17[39m
 [90m [92d709cd] [39m[92m+ IrrationalConstants v0.1.1[39m
 [90m [692b3bcd] [39m[92m+ JLLWrappers v1.7.0[39m
 [90m [682c06a0] [39m[92m+ JSON v0.21.4[39m
 [90m [7d188eb4] [39m[92m+ JSONSchema v0.3.4[39m
 [90m [4076af6c] [39m[92m+ JuMP v0.21.10[39m
 [90m [2ab3a3ac] [39m[92m+ LogExpFunctions v0.3.28[39m
 [90m [6c6e2e6c] [39m[92m+ MIMEs v1.1.0[39m
 [90m [1914dd2f] [39m[92m+ MacroTools v0.5.16[39m
 [90m [b8f27783] [39m[92m+ MathOptInterface v0.9.22[39m
 [90m [739be429] [39m[92m+ MbedTLS v1.1.9[39m
 [90m [d8a4904e] [39m[92m+ MutableArithmetics v0.2.22[39m
 [90m [77ba4419] [39m[92m+ NaNMath v0.3.7[39m
 [90m [bac558e1] [39m[92m+ OrderedCollections v1.8.1[39m
 [90m [69de0a69] [39m[92m+ Parsers v2.8.3[39m
 [90m [7f904dfe] [39m[92m+ PlutoUI v0.7.64[39m
 [90m [aea7be01] [39m[92m+ PrecompileTools v1.2.1[39m
 [90m [21216c6a] [39m[92m+ Preferences v1.4.3[39m
 [90m [189a3867] [39m[92m+ Reexport v1.2.2[39m
 [90m [276daf66] [39m[92m+ SpecialFunctions v1.8.8[39m
 [90m [90137ffa] [39m[92m+ StaticArrays v1.9.13[39m
 [90m [1e83bf80] [39m[92m+ StaticArraysCore v1.4.3[39m
 [90m [3bb67fe8] [39m[92m+ TranscodingStreams v0.9.13[39m
 [90m [410a4b4d] [39m[92m+ Tricks v0.1.10[39m
 [90m [5c2747f8] [39m[92m+ URIs v1.5.2[39m
 [90m [6e34b625] [39m[92m+ Bzip2_jll v1.0.9+0[39m
 [90m [e8aa6df9] [39m[92m+ GLPK_jll v5.0.0+0[39m
 [90m [efe28fd5] [39m[92m+ OpenSpecFun_jll v0.5.6+0[39m
 [90m [0dad84c5] [39m[92m+ ArgTools[39m
 [90m [56f22d72] [39m[92m+ Artifacts[39m
 [90m [2a0f44e3] [39m[92m+ Base64[39m
 [90m [ade2ca70] [39m[92m+ Dates[39m
 [90m [f43a241f] [39m[92m+ Downloads[39m
 [90m [7b1f6079] [39m[92m+ FileWatching[39m
 [90m [b77e0a4c] [39m[92m+ InteractiveUtils[39m
 [90m [b27032c2] [39m[92m+ LibCURL[39m
 [90m [76f85450] [39m[92m+ LibGit2[39m
 [90m [8f399da3] [39m[92m+ Libdl[39m
 [90m [37e2e46d] [39m[92m+ LinearAlgebra[39m
 [90m [56ddb016] [39m[92m+ Logging[39m
 [90m [d6f4376e] [39m[92m+ Markdown[39m
 [90m [a63ad114] [39m[92m+ Mmap[39m
 [90m [ca575930] [39m[92m+ NetworkOptions[39m
 [90m [44cfe95a] [39m[92m+ Pkg[39m
 [90m [de0858da] [39m[92m+ Printf[39m
 [90m [9abbd945] [39m[92m+ Profile[39m
 [90m [3fa0cd96] [39m[92m+ REPL[39m
 [90m [9a3f8284] [39m[92m+ Random[39m
 [90m [ea8e919c] [39m[92m+ SHA[39m
 [90m [9e88b42a] [39m[92m+ Serialization[39m
 [90m [6462fe0b] [39m[92m+ Sockets[39m
 [90m [2f01184e] [39m[92m+ SparseArrays[39m
 [90m [10745b16] [39m[92m+ Statistics[39m
 [90m [fa267f1f] [39m[92m+ TOML[39m
 [90m [a4e569a6] [39m[92m+ Tar[39m
 [90m [8dfed614] [39m[92m+ Test[39m
 [90m [cf7118a7] [39m[92m+ UUIDs[39m
 [90m [4ec0a83e] [39m[92m+ Unicode[39m
 [90m [e66e0078] [39m[92m+ CompilerSupportLibraries_jll[39m
 [90m [781609d7] [39m[92m+ GMP_jll[39m
 [90m [deac9b47] [39m[92m+ LibCURL_jll[39m
 [90m [29816b5a] [39m[92m+ LibSSH2_jll[39m
 [90m [c8ffd9c3] [39m[92m+ MbedTLS_jll[39m
 [90m [14a3606d] [39m[92m+ MozillaCACerts_jll[39m
 [90m [4536629a] [39m[92m+ OpenBLAS_jll[39m
 [90m [05823500] [39m[92m+ OpenLibm_jll[39m
 [90m [83775a58] [39m[92m+ Zlib_jll[39m
 [90m [8e850b90] [39m[92m+ libblastrampoline_jll[39m
 [90m [8e850ede] [39m[92m+ nghttp2_jll[39m
 [90m [3f19e933] [39m[92m+ p7zip_jll[39m
[32m[1m    Building[22m[39m GLPK â†’ `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/833dbc8fbb0554e31186df509d67fc2f78f1bb09/build.log`
[32m[1mPrecompiling[22m[39m project...
[32m  âœ“ [39m[90mGMP_jll[39m
[32m  âœ“ [39m[90mCodecBzip2[39m
[32m  âœ“ [39m[90mJSONSchema[39m
[32m  âœ“ [39m[90mGLPK_jll[39m
[32m  âœ“ [39m[90mMutableArithmetics[39m
[32m  âœ“ [39m[90mMathOptInterface[39m
[32m  âœ“ [39mGLPK
[32m  âœ“ [39mJuMP
  8 dependencies successfully precompiled in 49 seconds (52 already precompiled)
ªtext/plain§cell_idÙ$2e3d4b69-786e-4ccb-91ec-3b98f1f568e0¦kwargs�¢id´PlutoRunner_d1acb81e¤fileÙP/home/runner/.julia/packages/Pluto/6smog/src/runner/PlutoRunner/src/io/stdout.jl¥group¦stdout¥level®LogLevel(-555)§runningÂ¦output†¤body ¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÿäÓêÝ°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$2e3d4b69-786e-4ccb-91ec-3b98f1f568e0¹depends_on_disabled_cellsÂ§runtimeÏ   &44µpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$15037686-c495-42c3-b976-11ac753dde18Š¦queuedÂ¤logs�§runningÂ¦output†¤body£1.0¤mimeªtext/plain¬rootassigneeÀ²last_run_timestampËAÚÿêCÇ°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$15037686-c495-42c3-b976-11ac753dde18¹depends_on_disabled_cellsÂ§runtimeÎ®^µpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$68e07edd-55dd-45d8-9f8a-24ae75a20960Š¦queuedÂ¤logs�§runningÂ¦output†¤bodyÙa<bond def="xmax" unique_id="cI7pNeFaF6mJ"><input type='range' min='1' max='301' value='1'></bond>¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÿåëõ°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$68e07edd-55dd-45d8-9f8a-24ae75a20960¹depends_on_disabled_cellsÂ§runtimeÎÊ�3µpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂÙ$267e9766-e2c1-4006-abb0-ae69fba94052Š¦queuedÂ¤logs�§runningÂ¦output†¤bodyÚ¿<div style="opacity: 0.5;"><div class="markdown"><h3>Part 2b: make definitions explicit for Pluto</h3>
<p>Alternatively, you can manually assign to the variable that is secretly defined to make Pluto understand.</p>
<p>â›”ï¸� Don&#39;t:</p>
<pre><code class="language-julia">begin
	model &#61; Model&#40;GLPK.Optimizer&#41;

	@variable&#40;model, 20 &lt; y &lt; 30&#41;
	# global variable y is now defined, but Pluto does not know it

	...
end</code></pre>
<p>âœ”ï¸� Do:</p>
<pre><code class="language-julia">begin
	model &#61; Model&#40;GLPK.Optimizer&#41;

	y &#61; @variable&#40;model, 20 &lt; y &lt; 30&#41;
	# global variable y is now defined, and Pluto knows it

	...
end</code></pre>
</div></div>¤mime©text/html¬rootassigneeÀ²last_run_timestampËAÚÿå–Ðò°persist_js_stateÂ·has_pluto_hook_featuresÂ§cell_idÙ$267e9766-e2c1-4006-abb0-ae69fba94052¹depends_on_disabled_cellsÂ§runtimeÎò“¶µpublished_object_keys�¸depends_on_skipped_cellsÂ§erroredÂ±cell_dependenciesÞ Ù$e4d0ad7b-9e72-45c7-9eb9-0ed06567aef8„´precedence_heuristic	§cell_idÙ$e4d0ad7b-9e72-45c7-9eb9-0ed06567aef8´downstream_cells_map€²upstream_cells_map‚©model_opt‘Ù$95e0721d-321f-478c-8d02-0ac070008a5b¯objective_value�Ù$470eaa98-4073-11eb-349d-e9c34e5478c2„´precedence_heuristic	§cell_idÙ$470eaa98-4073-11eb-349d-e9c34e5478c2´downstream_cells_map�¥model’Ù$2717450b-8e9d-4be4-9156-53b2020a2e5dÙ$95e0721d-321f-478c-8d02-0ac070008a5b²upstream_cells_mapÞ ¼JuMP.MutableArithmetics.Zero�±JuMP.add_variable�¤GLPK‘Ù$2e3d4b69-786e-4ccb-91ec-3b98f1f568e0±JuMP._functionize�±JuMP.VariableInfo�Ù JuMP.MutableArithmetics.operate!�¥Model�Ù#JuMP._throw_error_for_invalid_sense�²JuMP.set_objective�©@variable�¤JuMP‘Ù$2e3d4b69-786e-4ccb-91ec-3b98f1f568e0³JuMP.add_constraint�³JuMP.build_variable�±JuMP._valid_model�µJuMP.build_constraint�¤xmax‘Ù$68e07edd-55dd-45d8-9f8a-24ae75a20960ª@objective�¾JuMP._error_if_cannot_register�«@constraint�Ù$9b4e18a3-669f-4bab-8c22-565428ebf299„´precedence_heuristic	§cell_idÙ$9b4e18a3-669f-4bab-8c22-565428ebf299´downstream_cells_map�§opacity‘Ù$267e9766-e2c1-4006-abb0-ae69fba94052²upstream_cells_map€Ù$cdda279d-60bf-495c-b796-a62e5dd1d699„´precedence_heuristic	§cell_idÙ$cdda279d-60bf-495c-b796-a62e5dd1d699´downstream_cells_map�§opacity‘Ù$267e9766-e2c1-4006-abb0-ae69fba94052²upstream_cells_map„¤Base�¤HTML�©@MIME_str�¤repr�Ù$8bc3d43a-1460-498b-baa8-fcb9a3338457„´precedence_heuristic	§cell_idÙ$8bc3d43a-1460-498b-baa8-fcb9a3338457´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$ce6d95f3-d745-4215-844c-727c9d90861d„´precedence_heuristic	§cell_idÙ$ce6d95f3-d745-4215-844c-727c9d90861d´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$759c0a90-bb03-456e-bbf6-8bf80b249c07„´precedence_heuristic	§cell_idÙ$759c0a90-bb03-456e-bbf6-8bf80b249c07´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$69a565bc-e250-4105-9b6b-3b9879dcb417„´precedence_heuristic	§cell_idÙ$69a565bc-e250-4105-9b6b-3b9879dcb417´downstream_cells_map€²upstream_cells_map‚©model_opt‘Ù$95e0721d-321f-478c-8d02-0ac070008a5b²termination_status�Ù$95e0721d-321f-478c-8d02-0ac070008a5b„´precedence_heuristic	§cell_idÙ$95e0721d-321f-478c-8d02-0ac070008a5b´downstream_cells_map�©model_opt”Ù$69a565bc-e250-4105-9b6b-3b9879dcb417Ù$e4d0ad7b-9e72-45c7-9eb9-0ed06567aef8Ù$15037686-c495-42c3-b976-11ac753dde18Ù$946b13ae-65f2-4844-a38a-693b2f01bad4²upstream_cells_map‚©optimize!�¥model‘Ù$470eaa98-4073-11eb-349d-e9c34e5478c2Ù$d5b9c438-b1e7-4417-870f-afdfc4ee7672„´precedence_heuristic	§cell_idÙ$d5b9c438-b1e7-4417-870f-afdfc4ee7672´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$2717450b-8e9d-4be4-9156-53b2020a2e5d„´precedence_heuristic	§cell_idÙ$2717450b-8e9d-4be4-9156-53b2020a2e5d´downstream_cells_map€²upstream_cells_map‚¥model‘Ù$470eaa98-4073-11eb-349d-e9c34e5478c2¤Text�Ù$946b13ae-65f2-4844-a38a-693b2f01bad4„´precedence_heuristic	§cell_idÙ$946b13ae-65f2-4844-a38a-693b2f01bad4´downstream_cells_map€²upstream_cells_map‚©model_opt‘Ù$95e0721d-321f-478c-8d02-0ac070008a5b¥value�Ù$b99f3213-f2c4-4d85-b34c-a60052571af3„´precedence_heuristic	§cell_idÙ$b99f3213-f2c4-4d85-b34c-a60052571af3´downstream_cells_map€²upstream_cells_map‚§@md_str�¨getindex�Ù$2e3d4b69-786e-4ccb-91ec-3b98f1f568e0„´precedence_heuristic§cell_idÙ$2e3d4b69-786e-4ccb-91ec-3b98f1f568e0´downstream_cells_map„£Pkg‘Ù$2e3d4b69-786e-4ccb-91ec-3b98f1f568e0¤GLPK‘Ù$470eaa98-4073-11eb-349d-e9c34e5478c2§PlutoUI�¤JuMP‘Ù$470eaa98-4073-11eb-349d-e9c34e5478c2²upstream_cells_map…§Pkg.add�£Pkg‘Ù$2e3d4b69-786e-4ccb-91ec-3b98f1f568e0¬Pkg.activate�¯Pkg.PackageSpec�©mktempdir�Ù$15037686-c495-42c3-b976-11ac753dde18„´precedence_heuristic	§cell_idÙ$15037686-c495-42c3-b976-11ac753dde18´downstream_cells_map€²upstream_cells_map‚©model_opt‘Ù$95e0721d-321f-478c-8d02-0ac070008a5b¥value�Ù$68e07edd-55dd-45d8-9f8a-24ae75a20960„´precedence_heuristic	§cell_idÙ$68e07edd-55dd-45d8-9f8a-24ae75a20960´downstream_cells_map�¤xmax‘Ù$470eaa98-4073-11eb-349d-e9c34e5478c2²upstream_cells_map‰¤Core�¤Base�¡:�·PlutoRunner.create_bond�«PlutoRunner�¯Core.applicable�¥@bind�¨Base.get�¦Slider�Ù$267e9766-e2c1-4006-abb0-ae69fba94052„´precedence_heuristic	§cell_idÙ$267e9766-e2c1-4006-abb0-ae69fba94052´downstream_cells_map€²upstream_cells_map„§@md_str�¢|>�§opacity’Ù$cdda279d-60bf-495c-b796-a62e5dd1d699Ù$9b4e18a3-669f-4bab-8c22-565428ebf299¨getindex�´cell_execution_orderÜ Ù$2e3d4b69-786e-4ccb-91ec-3b98f1f568e0Ù$d5b9c438-b1e7-4417-870f-afdfc4ee7672Ù$759c0a90-bb03-456e-bbf6-8bf80b249c07Ù$ce6d95f3-d745-4215-844c-727c9d90861dÙ$8bc3d43a-1460-498b-baa8-fcb9a3338457Ù$cdda279d-60bf-495c-b796-a62e5dd1d699Ù$9b4e18a3-669f-4bab-8c22-565428ebf299Ù$267e9766-e2c1-4006-abb0-ae69fba94052Ù$b99f3213-f2c4-4d85-b34c-a60052571af3Ù$68e07edd-55dd-45d8-9f8a-24ae75a20960Ù$470eaa98-4073-11eb-349d-e9c34e5478c2Ù$2717450b-8e9d-4be4-9156-53b2020a2e5dÙ$95e0721d-321f-478c-8d02-0ac070008a5bÙ$69a565bc-e250-4105-9b6b-3b9879dcb417Ù$e4d0ad7b-9e72-45c7-9eb9-0ed06567aef8Ù$15037686-c495-42c3-b976-11ac753dde18Ù$946b13ae-65f2-4844-a38a-693b2f01bad4´last_hot_reload_timeË        ©shortpath´jump inside Pluto.jl®process_status¥ready¤pathÙJ/home/runner/work/disorganised-mess/disorganised-mess/jump inside Pluto.jl­pluto_version¨v0.19.47®last_save_timeËAÚÿÔÊpTªcell_orderÜ Ù$2e3d4b69-786e-4ccb-91ec-3b98f1f568e0Ù$d5b9c438-b1e7-4417-870f-afdfc4ee7672Ù$759c0a90-bb03-456e-bbf6-8bf80b249c07Ù$ce6d95f3-d745-4215-844c-727c9d90861dÙ$8bc3d43a-1460-498b-baa8-fcb9a3338457Ù$267e9766-e2c1-4006-abb0-ae69fba94052Ù$cdda279d-60bf-495c-b796-a62e5dd1d699Ù$9b4e18a3-669f-4bab-8c22-565428ebf299Ù$b99f3213-f2c4-4d85-b34c-a60052571af3Ù$470eaa98-4073-11eb-349d-e9c34e5478c2Ù$2717450b-8e9d-4be4-9156-53b2020a2e5dÙ$95e0721d-321f-478c-8d02-0ac070008a5bÙ$68e07edd-55dd-45d8-9f8a-24ae75a20960Ù$69a565bc-e250-4105-9b6b-3b9879dcb417Ù$e4d0ad7b-9e72-45c7-9eb9-0ed06567aef8Ù$15037686-c495-42c3-b976-11ac753dde18Ù$946b13ae-65f2-4844-a38a-693b2f01bad4±published_objects€¥nbpkgŠ¯install_time_nsÀ¬instantiatedÃ²installed_versions€°terminal_outputs€§enabledÂ·restart_recommended_msgÀ´restart_required_msgÀ­busy_packages�¶waiting_for_permissionÂÙ,waiting_for_permission_but_probably_disabledÂ«cell_inputsÞ Ù$e4d0ad7b-9e72-45c7-9eb9-0ed06567aef8„§cell_idÙ$e4d0ad7b-9e72-45c7-9eb9-0ed06567aef8¤codeºobjective_value(model_opt)¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂÙ$470eaa98-4073-11eb-349d-e9c34e5478c2„§cell_idÙ$470eaa98-4073-11eb-349d-e9c34e5478c2¤codeÙÉlet
	global model = Model(GLPK.Optimizer)
	
	@variable(model, 0 <= x <= xmax)
	@variable(model, 0 <= y <= 30)
	
	@objective(model, Max, 5x + 3 * y)
	
	@constraint(model, con, 1x + 5y <= 3)
	
	model
end¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂÙ$9b4e18a3-669f-4bab-8c22-565428ebf299„§cell_idÙ$9b4e18a3-669f-4bab-8c22-565428ebf299¤codeÙ!opacity(op) = x -> opacity(x, op)¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÃÙ$cdda279d-60bf-495c-b796-a62e5dd1d699„§cell_idÙ$cdda279d-60bf-495c-b796-a62e5dd1d699¤codeÙ]opacity(x, op) = HTML("""<div style="opacity: $(op);">$(repr(MIME"text/html"(), x))</div>""")¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÃÙ$8bc3d43a-1460-498b-baa8-fcb9a3338457„§cell_idÙ$8bc3d43a-1460-498b-baa8-fcb9a3338457¤codeÙ¹md"""
To access variables from the model that are hidden by a let block, use the alternative syntax:


â›”ï¸� Don't:
```julia
value(y)
```

âœ”ï¸� Do:
```julia
value(model[:y])
```

"""¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÃÙ$ce6d95f3-d745-4215-844c-727c9d90861d„§cell_idÙ$ce6d95f3-d745-4215-844c-727c9d90861d¤codeÚJmd"""
## Part 2: secret definitions

JuMP's macros create global variables, which are not seen by Pluto. For example, `@variable(model, 0 < x < 1)` defines a global variable called `x`, while Pluto thinks that the global variable `x` was *referenced*, not assigned.

There are two ways to solve this.

### Part 2a: `let` block (recommended)
Place the macros inside a `let` block, to locally scope any secretly created variables.

â›”ï¸� Don't:
```julia
begin
	model = Model(GLPK.Optimizer)

	@variable(model, 20 < y < 30)
	# global variable y is now defined, but Pluto does not know it

	...
end
```

âœ”ï¸� Do:
```julia
let
	global model = Model(GLPK.Optimizer)

	@variable(model, 20 < y < 30)
	# locally scoped variable y is now defined. Pluto does not know about it, but since the global scope is unaffected, this is fine

	...
end
```
"""¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÃÙ$759c0a90-bb03-456e-bbf6-8bf80b249c07„§cell_idÙ$759c0a90-bb03-456e-bbf6-8bf80b249c07¤codeÚœmd"""
## Part 1: model mutations

Because JuMP's macros _modify_ a model, it is important the the **model construction is contained in a single cell**. Use a `let` block (more in Part 2).

â›”ï¸� Don't:
```julia
model = Model(GLPK.Optimizer)
```
```julia
@variable(model, 20 < y < 30)
```

âœ”ï¸� Do:
```julia
let
	global model = Model(GLPK.Optimizer)

	@variable(model, 20 < y < 30)

	...
end
```

#### optimize!

Similarly, `optimize!` will _modify_ the model, so I recommend calling it in the same cell as the model construction.

If, for the purpose of a narrative, you need the optimization to happen in a different cell, then use a "new state, new name" trick:

```julia
begin
	optimize!(model)
	model_optimized = model
end
```

In other cells, reference `model_optimized` to access `model` to guarantee that the model optimization has already happened:

```julia
# in other cells
value(model_optimized[:x])
```
	

"""¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÃÙ$69a565bc-e250-4105-9b6b-3b9879dcb417„§cell_idÙ$69a565bc-e250-4105-9b6b-3b9879dcb417¤code½termination_status(model_opt)¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂÙ$95e0721d-321f-478c-8d02-0ac070008a5b„§cell_idÙ$95e0721d-321f-478c-8d02-0ac070008a5b¤codeÙ,model_opt = let
	optimize!(model)
	model
end¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂÙ$d5b9c438-b1e7-4417-870f-afdfc4ee7672„§cell_idÙ$d5b9c438-b1e7-4417-870f-afdfc4ee7672¤codeÚûmd"""
# How to use JuMP in Pluto?

JuMP uses macros to form a domain-specific language. That is very cool! but unfortunately, Pluto has trouble understanding code with macros. This is a difficult problem that we currently working on, and it is getting closer to being fixed!

For any cell, it is important that Pluto correctly understands which variables are **referenced** and which are **defined**. Pluto's runtime uses this information to keep your global scope clean, and to reactively re-run cells.
"""¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÃÙ$2717450b-8e9d-4be4-9156-53b2020a2e5d„§cell_idÙ$2717450b-8e9d-4be4-9156-53b2020a2e5d¤code«Text(model)¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂÙ$946b13ae-65f2-4844-a38a-693b2f01bad4„§cell_idÙ$946b13ae-65f2-4844-a38a-693b2f01bad4¤code´value(model_opt[:y])¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂÙ$b99f3213-f2c4-4d85-b34c-a60052571af3„§cell_idÙ$b99f3213-f2c4-4d85-b34c-a60052571af3¤code³md"""
# Example
"""¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÃÙ$2e3d4b69-786e-4ccb-91ec-3b98f1f568e0„§cell_idÙ$2e3d4b69-786e-4ccb-91ec-3b98f1f568e0¤codeÚbegin
    import Pkg
    Pkg.activate(mktempdir())
    Pkg.add([
        Pkg.PackageSpec(name="JuMP", version="0.21"),
        Pkg.PackageSpec(name="GLPK", version="0.14"),
        Pkg.PackageSpec(name="PlutoUI", version="0.7"),
    ])
    using JuMP, GLPK, PlutoUI
end¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂÙ$15037686-c495-42c3-b976-11ac753dde18„§cell_idÙ$15037686-c495-42c3-b976-11ac753dde18¤code´value(model_opt[:x])¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂÙ$68e07edd-55dd-45d8-9f8a-24ae75a20960„§cell_idÙ$68e07edd-55dd-45d8-9f8a-24ae75a20960¤codeº@bind xmax Slider(1:.01:4)¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÂÙ$267e9766-e2c1-4006-abb0-ae69fba94052„§cell_idÙ$267e9766-e2c1-4006-abb0-ae69fba94052¤codeÚmd"""
### Part 2b: make definitions explicit for Pluto

Alternatively, you can manually assign to the variable that is secretly defined to make Pluto understand.

â›”ï¸� Don't:
```julia
begin
	model = Model(GLPK.Optimizer)

	@variable(model, 20 < y < 30)
	# global variable y is now defined, but Pluto does not know it

	...
end
```

âœ”ï¸� Do:
```julia
begin
	model = Model(GLPK.Optimizer)

	y = @variable(model, 20 < y < 30)
	# global variable y is now defined, and Pluto knows it

	...
end
```

""" |> opacity(.5)¨metadataƒ©show_logsÃ¨disabledÂ®skip_as_scriptÂ«code_foldedÃ«notebook_idÙ$b47c0b74-4aa4-11f0-1152-8f4584eee5fb«in_temp_dirÂ¨metadata€